import java.util.ArrayList;
import java.util.List;

/**
 * @Author:DarknessShadow
 * @description: 书集合类,既书架
 * @date 2020/5/8 16:43
 */
public class BookShelf implements Aggregate {

    private List books;
    private int last = 0;

    public BookShelf(int maxsize) {
        this.books = new ArrayList(maxsize);
    }

    public Book getBookAt(int index) {
        return (Book)books.get(index);
    }

    public void appendBook(Book book) {
        this.books.add(book);
        last++;
    }

    public int getLength(){
        return last;
    }

    @Override
    public Iterator iterator() {
        return new BookShelfIterator(this);
    }
}
